import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/team_user_entity.dart';

TeamUserEntity $TeamUserEntityFromJson(Map<String, dynamic> json) {
  final TeamUserEntity teamUserEntity = TeamUserEntity();
  final int? role = jsonConvert.convert<int>(json['role']);
  if (role != null) {
    teamUserEntity.role = role;
  }
  final List<TeamUserData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<TeamUserData>(e) as TeamUserData).toList();
  if (data != null) {
    teamUserEntity.data = data;
  }
  final String? bossName = jsonConvert.convert<String>(json['bossName']);
  if (bossName != null) {
    teamUserEntity.bossName = bossName;
  }
  return teamUserEntity;
}

Map<String, dynamic> $TeamUserEntityToJson(TeamUserEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['role'] = entity.role;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['bossName'] = entity.bossName;
  return data;
}

extension TeamUserEntityExtension on TeamUserEntity {
  TeamUserEntity copyWith({
    int? role,
    List<TeamUserData>? data,
    String? bossName,
  }) {
    return TeamUserEntity()
      ..role = role ?? this.role
      ..data = data ?? this.data
      ..bossName = bossName ?? this.bossName;
  }
}

TeamUserData $TeamUserDataFromJson(Map<String, dynamic> json) {
  final TeamUserData teamUserData = TeamUserData();
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    teamUserData.uid = uid;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    teamUserData.name = name;
  }
  final int? role = jsonConvert.convert<int>(json['role']);
  if (role != null) {
    teamUserData.role = role;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    teamUserData.mobile = mobile;
  }
  return teamUserData;
}

Map<String, dynamic> $TeamUserDataToJson(TeamUserData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['name'] = entity.name;
  data['role'] = entity.role;
  data['mobile'] = entity.mobile;
  return data;
}

extension TeamUserDataExtension on TeamUserData {
  TeamUserData copyWith({
    String? uid,
    String? name,
    int? role,
    String? mobile,
  }) {
    return TeamUserData()
      ..uid = uid ?? this.uid
      ..name = name ?? this.name
      ..role = role ?? this.role
      ..mobile = mobile ?? this.mobile;
  }
}